<template>
	<view class="career">
		<view class="close" @click="$emit('close')">
			<image :src="`${baseImageUrl}/common/close1.png`"></image>
		</view>
		<view class="title">
			<view class="box">
				<view class="decorate"></view>
				<view class="name">{{career_text}}</view>
			</view>
		</view>
		<view class="cover">
			<image :src="career_avatar"></image>
		</view>
		<view class="grade">
			<view class="name">
				<text>等级：</text>
				<text class="value">{{role_level_name}}</text>
			</view>
			<view class="btn" @click="show=true">升级人物</view>
		</view>
		<!-- <view class="pet">携带宠物</view>
		<view class="pet_image">
			<view class="img_box">
				<image :src="pet_cover"></image>
			</view>
		</view>
		<view class="sub_title">
			<image :src="`${baseImageUrl}/home/xs.png`"></image>
			<text>宠物技能</text>
		</view>
		<view class="list">
			<view class="item" v-for="item in list">
				<image :src="item.skill.img"></image>
				<text>{{item.skill.name}}</text>
			</view>
		</view> -->
		<u-popup :show="show" bgColor="transparent" mode="center" @close="close">
			<UserLevel :career_avatar="career_avatar" :field_text="field_text" @close="close" />
		</u-popup>
	</view>
</template>

<script>
	import {
		career
	} from '@/utils/config.js';
	import {
		userInfo
	} from '@/request/api.js';
	import UserLevel from '@/components/home/UserLevel.vue';
	export default {
		components: {
			UserLevel
		},
		props: {
			field_text: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				career_text: "",
				career_avatar: "",
				role_level_name: "",
				pet_cover: "",
				list: [],
				show: false
			}
		},
		created() {
			this.getInfo();
		},
		methods: {
			async getInfo() {
				let {
					user,
					pet,
					pet_kill
				} = await userInfo();
				this.role_level_name = user.role_level_name;
				this.pet_cover = pet.product_cover;
				this.list = pet_kill;

				const item = career[user.role_id];
				this.career_text = item.name;
				this.career_avatar = item.avatar;
			},
			close() {
				this.show = false;
				this.getInfo();
			}
		}
	}
</script>

<style scoped lang="scss">
	.career {
		width: 100vw;
		height: 650rpx;
		padding: 35rpx 75rpx 0;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/750_1120.png) no-repeat;
		background-size: 100% 100%;
		position: relative;

		.close {
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			transform: translate(20rpx, -45rpx);
			z-index: 2;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.title {
			display: flex;
			justify-content: center;

			.box {
				width: 256rpx;
				height: 54rpx;
				display: flex;
				justify-content: center;
				position: relative;

				.decorate {
					width: 256rpx;
					height: 29rpx;
					background: url(#{$baseImageUrl}/home/title.png) no-repeat;
					background-size: 100% 100%;
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
				}
			}

			.name {
				width: 180rpx;
				height: 54rpx;
				line-height: 54rpx;
				text-align: center;
				color: #494338;
				font-size: 42rpx;
				font-weight: 400;
				font-family: LiSu;
				background: url(#{$baseImageUrl}/home/name.png) no-repeat;
				background-size: 100% 100%;
			}
		}

		.cover {
			width: 372rpx;
			height: 372rpx;
			background: url(#{$baseImageUrl}/bg/372_372.png) no-repeat;
			background-size: 100% 100%;
			margin: 32rpx auto;
			display: flex;
			justify-content: center;
			align-items: center;

			image {
				width: 300rpx;
				height: 300rpx;
			}
		}

		.grade {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.name {
				color: #494338;
				font-size: 42rpx;
				font-weight: 400;
				font-family: LiSu;

				.value {
					font-family: LiSu;
					padding-left: 15rpx;
					box-sizing: border-box;
				}
			}

			.btn {
				width: 200rpx;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
				font-family: SimSun;
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;
			}
		}

		.pet {
			width: 100%;
			height: 70rpx;
			line-height: 70rpx;
			text-align: center;
			color: #494338;
			font-size: 40rpx;
			font-weight: 400;
			margin-top: 32rpx;
			background: url(#{$baseImageUrl}/bg/title.png) no-repeat;
			background-size: 100% 100%;
		}

		.pet_image {
			padding: 10rpx 0;
			box-sizing: border-box;
			display: flex;
			justify-content: center;

			.img_box {
				width: 220rpx;
				height: 220rpx;
				// border-radius: 50%;
				// padding: 10rpx;
				box-sizing: border-box;
				background: url(#{$baseImageUrl}/home/pet.png) no-repeat;
				background-size: 100% 100%;
				// overflow: hidden;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 50%;
			}
		}

		.sub_title {
			display: flex;
			align-items: center;

			image {
				width: 32rpx;
				height: 32rpx;
			}

			text {
				line-height: 32rpx;
				color: #494338;
				font-size: 32rpx;
				font-weight: 400;
				font-family: SimSun;
				padding-left: 12rpx;
				box-sizing: border-box;
			}
		}

		.list {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.item {
				width: 50%;
				margin-top: 15rpx;
				display: flex;
				align-items: center;

				image {
					width: 40rpx;
					height: 40rpx;
					border-radius: 50%;
				}

				text {
					color: #494338;
					font-size: 28rpx;
					font-weight: 400;
					font-family: SimSun;
					padding-left: 5rpx;
					box-sizing: border-box;
				}
			}
		}
	}
</style>